=<template>
	<view>
		<my-bar v-if="currentTabBarComponent=='search'" type="search"></my-bar>
		<my-bar v-if="currentTabBarComponent=='back'" type="back"></my-bar>
		<home v-if="currentTab=='home'" :listData="listData" :swipers="swipers" :navs="navs" :notices="notices"></home>
		<ucenter v-if="currentTab=='ucenter'"></ucenter>
		<my-tabbar @change="switchTab" :tabbars="tabbars"></my-tabbar>
	</view>
</template>

<script>
	import home from '@/components/my-index.vue'
	import ucenter from '@/pages/user/index.vue'
	import service from '../../common/service.js';
	import {
		mapState,
		mapMutations,
		actions
	} from 'vuex';

	export default {
		components: {
			home,
			ucenter
		},
		mixins: [service],
		data() {
			return {
				currentTab: 'home'
			};
		},
		/*  */
		methods: {
			switchTab(e) {
				this.currentTab = e;
			}
		},
		computed: {
			// 映射带有命名空间的state，第一个参数模块名
			...mapState("pages", {
				// 箭头函数可使代码更简练
				listData: state => state.home.listData
			}),
			...mapState("base", ['tabbars', 'swipers', 'navs', 'notices']),
			currentTabBarComponent: function() {
				if (this.currentTab == "home") {
					return "search";
				} else if (this.currentTab == "ucenter") {
					return "";
				} else {
					return "back";
				}
				return this.currentTab;
			},
			currentTabContentComponent: function() {
				return this.currentTab;
			}
		},
		onLoad() {},
		onPullDownRefresh() { //下拉刷新   
		},
		onPageScroll(res) {}
	}
</script>

<style>

</style>
